/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: xiaotutu
 * Date: 2023-10-31
 * Time: 19:15
 */



/*public class Test {

    public static int add(int a, int b) {
        return a + b;
    }

    public static double add(double a, double b) {
        return a + b;
    }

    public static void main(String[] args) {
        System.out.println(add(1, 2));
        System.out.println(add(1.5, 2.5));
    }
}*/

/*class Animal {
    public String name;
    public int age;
    public Animal() {
        eat();
        System.out.println("不带参数的构造方法！Animal");
    }

    public Animal(String name,int age){
        this.name = name;
        this.age = age;
    }
    public void eat() {
        System.out.println(this.name+" 正在吃饭！");
    }
}
class Dog extends Animal {
    public Dog() {
        System.out.println("不带参数Dog！");
    }
    public Dog(String name,int age) {
        super(name,age);
    }

    public void bark() {
        System.out.println(this.name +" 正在旺旺旺！！");
    }

    @Override
    public void eat() {
        System.out.println(this.name+ " 正在吃狗粮！");
    }
}
class Cat extends Animal {
    public Cat() {
        super("haha",10);
        System.out.println("不带参数Cat！");
    }
    public void mimi() {
        System.out.println(this.name+" 正在喵喵喵！");
    }

    public void eat() {
        System.out.println(this.name+" 正在吃猫粮！");
    }
}*/

/*public class Test {

    public static void main(String[] args) {
        Animal animal = new Dog();

    }

    public static void main5(String[] args) {
        Animal animal = new Dog("wangwang",1);
        Dog dog = (Dog)animal;
        dog.bark();

        if(animal instanceof Cat) {
            Cat cat = (Cat) animal;
            cat.mimi();
        }

    }


    public static void testFunc(Animal animal) {
        animal.eat();
    }

    public static void main4(String[] args) {
        Dog dog = new Dog("wangwang",1);
        testFunc(dog);
        System.out.println("===========");
        Cat cat = new Cat();
        testFunc(cat);
    }



    public static Animal testFunc2() {
        return new Dog();
    }

    public static Dog testFunc3() {
        return new Dog();
    }

    public static void main3(String[] args) {
        Animal animal = testFunc3();

        Dog dog = new Dog("wangwang",1);
        testFunc(dog);

    }

    public static void main2(String[] args) {
        *//*Dog dog = new Dog("wangwang",1);
        Animal animal = dog;*//*
        Animal animal = new Dog("wangwang",1);
        animal.eat();
    }
    public static void main1(String[] args) {
        Dog dog = new Dog("wangwang",1);
        dog.eat();

        Cat cat = new Cat();
        cat.eat();

    }
}*/


class Animal {
    public String name;
    public int age;
    public Animal() {
        eat();
        System.out.println("不带参数的构造方法！Animal");
    }

    public Animal(String name,int age){
        this.name = name;
        this.age = age;
    }
    public void eat() {
        System.out.println(this.name+" 正在吃饭！");
    }
}
class Dog extends Animal {
    public Dog() {
        System.out.println("不带参数Dog！");
    }
    public Dog(String name,int age) {
        super(name,age);
    }

    public void bark() {
        System.out.println(this.name +" 正在旺旺旺！！");
    }

    @Override
    public void eat() {
        System.out.println(this.name+ " 正在吃狗粮！");
    }
}
class Cat extends Animal {
    public Cat() {
        super("haha",10);
        System.out.println("不带参数Cat！");
    }
    public void mimi() {
        System.out.println(this.name+" 正在喵喵喵！");
    }

    public void eat() {
        System.out.println(this.name+" 正在吃猫粮！");
    }
}

public class Test {
    public static void main(String[] args) {
        Dog dog = new Dog();
        dog.eat();
        System.out.println("=============");
        Cat cat = new Cat();
    }
}